function school() {
  hide_all();
  set_university_all_out();
  set_btn_color_out();
  document.getElementById("button1-content").style.display = "block";
}

function show_year() {
  hide_all();
  document.getElementById("button2-content").style.display = "block";
}

function hide_all() {
  document.getElementById("button2-content").style.display = "none";
  document.getElementById("button1-content").style.display = "none";
  document.getElementById("tip_box").style.display = "none";
}

function replace_text(clicked_id) {
  document.getElementById("button2").innerHTML = clicked_id;
  hide_all();
}

function replace_school_text(school) {
  document.getElementById("button1").innerHTML = school;
  hide_all();
}

function set_btn_color_in(id) {
  document.getElementById(id).style.backgroundColor = "orange";
}

function set_btn_color_out() {
  document.getElementById("jiangxi_b").style.backgroundColor = "white";
  document.getElementById("hubei_b").style.backgroundColor = "white";
  document.getElementById("hunan_b").style.backgroundColor = "white";
  document.getElementById("guangdong_b").style.backgroundColor = "white";
  document.getElementById("jiangsu_b").style.backgroundColor = "white";
  document.getElementById("shanxi_b").style.backgroundColor = "white";
  document.getElementById("A_b").style.backgroundColor = "white";
  document.getElementById("B_b").style.backgroundColor = "white";
  document.getElementById("C_b").style.backgroundColor = "white";
  document.getElementById("D_b").style.backgroundColor = "white";
}

function set_university_all_out() {
  document.getElementById("jiangxi-universities").style.display = "none";
  document.getElementById("hubei-universities").style.display = "none";
  document.getElementById("hunan-universities").style.display = "none";
  document.getElementById("guangdong-universities").style.display = "none";
  document.getElementById("jiangsu-universities").style.display = "none";
  document.getElementById("shanxi-universities").style.display = "none";
  document.getElementById("default-universities").style.display = "none";
}

function show_university(province_num) {
  set_btn_color_out();
  set_university_all_out();
  switch (province_num) {
    case 1:
      set_btn_color_in("jiangxi_b");
      document.getElementById("jiangxi-universities").style.display = "block";
      break;
    case 2:
      set_btn_color_in("hubei_b");
      document.getElementById("hubei-universities").style.display = "block";
      break;
    case 3:
      set_btn_color_in("hunan_b");
      document.getElementById("hunan-universities").style.display = "block";
      break;
    case 4:
      set_btn_color_in("guangdong_b");
      document.getElementById("guangdong-universities").style.display = "block";
      break;
    case 5:
      set_btn_color_in("jiangsu_b");
      document.getElementById("jiangsu-universities").style.display = "block";
      break;
    case 6:
      set_btn_color_in("shanxi_b");
      document.getElementById("default-universities").style.display = "block";
      break;
    case 7:
      set_btn_color_in("A_b");
      document.getElementById("default-universities").style.display = "block";
      break;
    case 8:
      set_btn_color_in("B_b");
      document.getElementById("default-universities").style.display = "block";
      break;
    case 9:
      set_btn_color_in("C_b");
      document.getElementById("default-universities").style.display = "block";
      break;
    case 10:
      set_btn_color_in("D_b");
      document.getElementById("default-universities").style.display = "block";
      break;
  }
}

function email_bool(szMail) {
  var szReg = /^([0-9a-zA-Z_\.\-\u4e00-\u9fa5])+\@([0-9a-zA-Z_\.\-\])+\.([a-zA-Z]{2,8})$/;

  var bChk = szReg.test(szMail);

  return bChk;
}

function hide_sign_in() {
  document.getElementById("sign_list").style.display = "none";

  document.getElementById("block_span").style.display = "block";
  document.getElementById("re_sign").style.display = "block";
}

function show_sign_in() {
  document.getElementById("success_box").style.display = "none";
  document.getElementById("input_school").style.display = "block";
  document.getElementById("button1").style.display = "block";
  document.getElementById("span01").style.display = "block";
  document.getElementById("span02").style.display = "block";
  document.getElementById("button2").style.display = "block";
  document.getElementById("input3").style.display = "block";
  document.getElementById("div_baoming").style.display = "block";
  document.getElementById("block_span").style.display = "none";
  document.getElementById("re_sign").style.display = "none";
}

function hide_success_box() {
  document.getElementById("success_box").style.display = "none";
  hide_all()

}

function hide_failed_box() {
  document.getElementById("failed_box").style.display = "none";
  hide_all()
}

function is_leagal() {
  hide_all();
  var school_name = document.getElementById("button1").innerText;
  var year_in = document.getElementById("button2").innerText;
  var e_mail = document.getElementById("input3").value;
  document.getElementById("success_box").style.display = "none";
  document.getElementById("failed_box").style.display = "none";
  document.getElementById("tip_box").style.display = "block";

  if (school_name == "选中示例大学") {
    var x = document.getElementById("failed_box");
    x.style.display = "block";
    x.innerHTML = "学校不符合要求，请重新输入";
    setTimeout("hide_failed_box()", 3000);
  } else if (year_in == "20xx") {
    var x = document.getElementById("failed_box");
    x.style.display = "block";
    x.innerHTML = "入学年份不符合要求，请重新输入";
    setTimeout("hide_failed_box()", 3000);
  } else if (!email_bool(e_mail)) {
    var x = document.getElementById("failed_box");
    x.style.display = "block";
    x.innerHTML = "邮件地址不符合要求，请重新输入";
    setTimeout("hide_failed_box()", 3000);
  } else {
    var x = document.getElementById("failed_box");
    var y = document.getElementById("success_box");
    x.style.display = "none";
    y.style.display = "block";
    y.innerHTML =
      "恭喜您，来自选" +
      school_name +
      year_in +
      "级的" +
      e_mail +
      "同学，您的报名信息已经记录，请关注您的邮件";
    hide_sign_in();
    setTimeout("hide_success_box()", 3000);
  }
}


function handle_selected(id_class) {
  var bar_id , show_id;
  if (id_class == "all_class"){
    bar_id = "selected1";
    show_id = "all_class";
  }else if (id_class == "all_HTML"){
    bar_id = "selected2";
    show_id = "html_class";
  }else if (id_class == "all_CSS"){
    bar_id = "selected3";
    show_id = "css_class";
  }else{
    bar_id = "selected4";
    show_id = "JavaScript_class";
  }
  
  show_select_bar(bar_id);
  empathy_line(id_class);
  show_class(show_id);
}

function show_class(id_class){
  hide_all_class();
  if (id_class == "all_class"){
    document.getElementById("css_class").style.display = "block";
    document.getElementById("html_class").style.display = "block";
    document.getElementById("JavaScript_class").style.display = "block";
  }else if(id_class == "css_class"){
    document.getElementById("css_class").style.display = "block";
  }else if(id_class == "html_class"){
    document.getElementById("html_class").style.display = "block";
  }else if(id_class == "JavaScript_class"){
    document.getElementById("JavaScript_class").style.display = "block";
  }
}

function hide_all_class(){
  document.getElementById("css_class").style.display = "none";
  document.getElementById("html_class").style.display = "none";
  document.getElementById("JavaScript_class").style.display = "none";
}

function empathy_line(id_class) {
  document.getElementById("all_class").style.fontWeight="normal";
  document.getElementById("all_HTML").style.fontWeight="normal";
  document.getElementById("all_CSS").style.fontWeight="normal";
  document.getElementById("all_JavaScript").style.fontWeight="normal";

  document.getElementById(id_class).style.fontWeight = "bolder";
}

function show_select_bar(bar_id) {
  document.getElementById("selected1").style.display = "none";
  document.getElementById("selected2").style.display = "none";
  document.getElementById("selected3").style.display = "none";
  document.getElementById("selected4").style.display = "none";
  document.getElementById(bar_id).style.display = "block";
}